
document.querySelector('#btn-register').addEventListener('click', async function (e) {
    e.preventDefault()
    let unamestr = /^[a-zA-Z0-9]{8,30}$/
    let passwordstr = /^[a-zA-Z0-9]{6,30}$/
    const form = document.querySelector('.register-form')
    const formdata = serialize(form, { hash: true, empty: true })
    if (unamestr.test(formdata.username) && passwordstr.test(formdata.password)) {
        let { data: res } = await axios({
            url: '/register',
            method: 'POST',
            data: formdata
        })
        console.log(res)
        pxmu.success('注册成功')
        location.href = './login.html'
    } else {
        alert('用户名或密码格式错误')
    }

})